<template>
  <div class="type-select">
    <div class="type-name">{{typeTitle}}</div>
    <div class="type-list-body" v-if="typeList.length">
      <div
        :class="[activeId === item.id ? 'item-active' : '']"
        v-for="item in typeList"
        :key="item.id"
        @click="handleSelect(item)"
      >{{ item.name }}</div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'TypeSelect',
  props: {
    activeId: Number,
    typeTitle: String,
    typeList: Array,
  },
  methods: {
    handleSelect(data) {
      this.$emit('handleSelect', {typeName: this.typeTitle, ...data})
    }
  }
};
</script>

<style scoped lang="scss">
.type-select {
  width: 100%;
  .type-name {
    height: 40px;
    line-height: 40px;
    color: #202020;
    font-size: 14px;
  }
  .type-list-body {
    width: 100%;
    max-height: 12vh;
    overflow: auto;
    display: flex;
    justify-content: flex-start;
    flex-wrap: wrap;
    & > div {
      padding: 1vh 2vw;
      margin: 0.5vh 2vw;
      background-color: #f6f6f6;
      color: #929292;
      font-size: 12px;
      border-radius: 6px;
      height: 3vh;
      line-height: 3vh;
    }
    .item-active {
      color: #FF7E00;
      background-color: #FFF3EB;
    }
  }
}
</style>
